< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03090303.xhp

(section: ongosub) (bookmark: bm_id3153897)
On...GoSub statement
On...GoTo statement

On... GoSub ステートメント
On... GoTo ステートメント

On...GoSub Statement; On...GoTo Statement [Runtime]
On...GoSub ステートメント; On...GoTo ステートメント [実行時](hd_id3153897.1)

Branches to one of several specified lines in the program code, depending on the value of a numeric expression.
プログラムコード上に複数の指定行を設けておき、与えられる数値表式を基にして、いずれか 1 つの行に分岐します。(par_id3150359.2)

(/section: ongosub)

Syntax:
構文:(hd_id3148798.3)

On N GoSub Label1[, Label2[, Label3[,...]]]
On N GoSub Label1[, Label2[, Label3[,...]]](par_id3154366.4)

On NumExpression GoTo Label1[, Label2[, Label3[,...]]]
On NumExpression GoTo Label1[, Label2[, Label3[,...]]](par_id3150769.5)

Parameters:
パラメータ:(hd_id3156215.6)

NumExpression: Any numeric expression between 0 and 255 that determines which of the lines the program branches to. If NumExpression is 0, the statement is not executed. If NumExpression is greater than 0, the program jumps to the label that has a position number that corresponds to the expression (1 = First label; 2 = Second label)
NumExpression: プログラム実行行の分岐先を示す、0 から 255 までの数値表式。NumExpression の指定値が 0 であると、このステートメントは実行されません。NumExpression が 0 よりも大きい場合は、指定値に該当するラベルにプログラム実行行がジャンプします (1 = 最初のラベル; 2 = 次のラベル)。(par_id3148673.7)

Label: Target line according to GoTo or GoSub structure.
Label: GoTo および GoSub でラベル付けされたターゲット行。(par_id3153194.8)

Note Icon 注マーク The GoTo or GoSub conventions are valid.
分岐方式の指定には GoTo および GoSub が使用できます。(par_id3156442.9)

Example:
例:(hd_id3148645.10)

Sub ExampleOnGosub
Sub ExampleOnGosub(par_id3154014.12)

Dim iVar As Integer
Dim iVar As Integer(par_id3153158.13)

Dim sVar As String
Dim sVar As String(par_id3154490.14)

iVar = 2
iVar = 2(par_id3155417.15)

sVar =""
sVar =""(par_id3154730.16)

On iVar GoSub Sub1, Sub2
On iVar GoSub Sub1, Sub2(par_id3154942.17)

On iVar GoTo Line1, Line2
On iVar GoTo Line1, Line2(par_id3149378.18)

Exit Sub
Exit Sub(par_id3153416.19)

Sub1:
Sub1:(par_id3154015.20)

sVar =sVar & " From Sub 1 to" : Return
sVar =sVar & " From Sub 1 to" : Return(par_id3153948.21)

Sub2:
Sub2:(par_id3150750.22)

sVar =sVar & " From Sub 2 to" : Return
sVar =sVar & " From Sub 2 to" : Return(par_id3153708.23)

Line1:
Line1:(par_id3155067.24)

sVar =sVar & " Label 1" : GoTo Ende
sVar =sVar & " Label 1" : GoTo Ende(par_id3150321.25)

Line2:
Line2:(par_id3149019.26)

sVar =sVar & " Label 2"
sVar =sVar & " Label 2"(par_id3155764.27)

Ende:
Ende:(par_id3153711.28)

MsgBox sVar,0,"On...Gosub"
MsgBox sVar,0,"On...Gosub"(par_id3154253.29)

End Sub
End Sub(par_id3149565.30)


< Prev / Next >